package org.rambadger.command;

import com.yammer.dropwizard.Service;
import com.yammer.dropwizard.cli.EnvironmentCommand;
import com.yammer.dropwizard.config.Environment;
import net.sourceforge.argparse4j.inf.Namespace;
import org.rambadger.command.axon.AxonBundle;

class RebuildViewsCommand extends EnvironmentCommand<CommandConfiguration> {
    private final AxonBundle axon;

    public RebuildViewsCommand(Service service, AxonBundle axon) {
        super(service, "rebuild", "Rebuild the views from the event store.");
        this.axon = axon;
    }

    @Override
    protected void run(Environment environment, Namespace namespace, CommandConfiguration configuration) throws Exception {
        axon.getReplayingCluster().startReplay();
    }
}
